<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>{{ collectOption.student_name }}-{{ collectOption.corner_name }}-实时采集</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <SearchModle dataKey="studentCorner" @searchFn="searchFn"></SearchModle>
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
                ref="multipleTable"
                :data="arryList"
                :border="tableoption.tableBorder"
                tooltip-effect="dark">
              <el-table-column
                  label="采集时间"
                  width="160"
                  align="center">
                <template slot-scope="scope">
                  {{ scope.row.create_time }}
                </template>
              </el-table-column>
              <el-table-column
                  label="采集人"
                  width="100"
                  align="center">
                <template slot-scope="scope">
                  {{ scope.row.user.realname }}
                </template>
              </el-table-column>
              <el-table-column
                  label="采集图片"
                  align="center">
                <template slot-scope="scope">
                  <viewerModle type="2" :imgSrc="scope.row.picSrc"></viewerModle>
                </template>
              </el-table-column>
              <el-table-column
                  label="采集视频" width="80" align="center">
                <template slot-scope="scope">
                  <span class="showpicVideo" @click="showVideoSrc(scope.row.video)" v-if="scope.row.video">查看视频</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="采集内容"align="center">
                <template slot-scope="scope">
                  {{ scope.row.content }}
                </template>
              </el-table-column>

            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbarLine">
          <el-pagination
              background
              :page-size="page.pagesize"
              :current-page="page.pageindex"
              layout="total, prev, pager, next"
              :total="page.total"
              @current-change="handleSizeChange"></el-pagination>
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button type="primary" @click="closePOpup" size="small">确定</el-button>
      </div>
    </div>
    <activeVideoDialog :videosrcCheck="videosrcCheck" :visible.sync="dialogvideoVisible"></activeVideoDialog>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js'

export default {
  props: ['visible', 'collectOption'], // commoent 学生点评 collection 学生采集
  data() {
    return {
      dialogVisible: false,
      arearBox: '',
      tableoption: tableoption,
      editId: this.$route.query,
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      arryList: [],
      value1: '',
      passTime: 0, // 合格时间
      joinTime: 0, // 参与时间
      videosrcCheck: '',
      dialogvideoVisible: false,
      searchForm: {}
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.InitFn()
      }else{
        this.arryList = []
      }
    }
  },
  created() {
  },
  methods: {
    // 初始化
    async InitFn() {
      this.searchForm.student_id = this.collectOption.student_id;
      this.searchForm.corner_id = this.collectOption.corner_id;
      this.searchForm.p = this.page.pageindex;
      let data = await this.$post(this.api.corner_comment_index, this.searchForm);
      console.log('data:', data)
      for (let i in data.list.data) {
        data.list.data[i].picSrc = data.list.data[i].pic.split(',')
      }
      this.arryList = data.list.data
      this.page.total = data.list.total
    },
    handleEdit(index) {
      this.$router.push('/CornerApplyHestoryDetail?id=' + this.arryList[index].id)
    },
    goBack() {
      this.$router.go(-1)
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    showClassList(indexList, index) {
      this.$router.push('/CornerApplyHestoryDetail?corner_id=' + this.arryList[indexList].corner_id + '&class_id=' + this.arryList[indexList].apply_class[index].id)
    },
    addActive(index) {
      this.$router.push('/statudentAtive?id=' + this.arryList[index].id)
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    showVideoSrc(videoSrc) {
      this.videosrcCheck = videoSrc
      this.dialogvideoVisible = true
    },
    searchFn(option) {
      console.log('收到搜索数据：', option);
      this.searchForm = this.getJson(option);
      if(option.start_time){
        this.searchForm.start_time = option.start_time[0];
        this.searchForm.end_time = option.start_time[1];
      }else{
        this.searchForm.start_time = '';
        this.searchForm.end_time = '';
      }
      this.InitFn();
    },
    getJson(option){
      return JSON.parse(JSON.stringify(option))
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 60%;
  height: 70%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 20px 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}
</style>


